package demo.practice.stack;

import java.util.Stack;

public class Offer09 {


}

class CQueue{
    private Stack<Integer> in;
    private Stack<Integer> out;
    public CQueue() {
        in= new Stack<>();
        out= new Stack<>();
    }

    public void appendTail(int value) {
        in.add(value);

    }

    public int deleteHead() {
        if(in.size()==0&& out.size()==0)
            return -1;

        if(out.size()>0)
            return out.pop();
        else{
            //需要倒栈操作，也就是将in的所有元素都转移到out中
            while (in.size()>0)
                out.add(in.pop());

            return out.pop();
        }
    }
}
